
<%@ page import="com.auctionhaus.Customer" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'customer.label', default: 'Customer')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="body">
            <h1><g:message code="default.show.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="dialog">
                <table>
                    <thead>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="customer.id.label" default="Id" /></td>
                            <td valign="top" class="name"><g:message code="customer.emailAddress.label" default="Email Address" /></td>
                            <td valign="top" class="name"><g:message code="customer.creationDate.label" default="Creation Date" /></td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td valign="top" class="value">${fieldValue(bean: customerInstance, field: "id")}</td>
                            <td valign="top" class="value">${fieldValue(bean: customerInstance, field: "emailAddress")}
                            <td valign="top" class="value">${fieldValue(bean: customerInstance, field: "date")}</td>
                        </tr>
                    </tbody>
                </table>
                <g:if test="${session?.customer?.getId() == customerInstance.getId() || session?.customer?.isAdminRole()}">
                    <div class="buttons">
                        <g:form>
                            <g:hiddenField name="id" value="${customerInstance?.id}" />
                            <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
                            <g:if test="${session?.customer?.isAdminRole() && session?.customer?.getId() != customerInstance.getId()}">
                                <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                            </g:if>
                        </g:form>
                    </div>
                </g:if>
            </div>

            <g:set var="currentListings" value="${message(code: 'listings.label', default: 'Listings')}" />
            <h1><g:message code="show.descriptive.label" args="['All', currentListings]" /></h1>

            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="id" title="${message(code: 'listing.id.label', default: 'Id')}" />
                            <g:sortableColumn property="listName" title="${message(code: 'listing.listName.label', default: 'List Name')}" />
                            <g:sortableColumn property="creationDate" title="${message(code: 'listing.creationDate.label', default: 'Creation Date')}" />
                            <g:sortableColumn property="description" title="${message(code: 'listing.description.label', default: 'Description')}" />
                            <g:sortableColumn property="startBidPrice" title="${message(code: 'listing.startBidPrice.label', default: 'Starting Bid Price')}" />
                            <g:sortableColumn property="endDateTime" title="${message(code: 'listing.endDateTime.label', default: 'End Date Time')}" />
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${customerInstance.listings}" status="i" var="listingInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "id")}</td>
                            <td><g:link controller="listing" action="show" id="${listingInstance.id}">${fieldValue(bean: listingInstance, field: "listName")}</g:link></td>
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "creationDate")}</td>
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "description")}</td>
                            <td valign="top" class="value"><g:formatNumber number="${listingInstance.startBidPrice}" type="currency" currencyCode="USD" /></td>
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "endDateTime")}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>

            <g:set var="bidLabel" value="${message(code: 'bid.label', default: 'Bid')}" />
            <h1><g:message code="show.descriptive.label" args="[bidLabel, 'History']" /></h1>

            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="listName" title="${message(code: 'listing.listName.label', default: 'List Name')}" />
                            <g:sortableColumn property="amount" title="${message(code: 'bid.amount.label', default: 'Bid Amount')}" />
                            <g:sortableColumn property="date" title="${message(code: 'bid.date.label', default: 'Bid Date')}" />
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${customerInstance.bid}" status="i" var="bidInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td><g:link controller="listing" action="show" id="${ bidInstance.listing.id}">${fieldValue(bean: bidInstance.listing, field: "listName")}</g:link></td>
                            <td valign="top" class="value"><g:formatNumber number="${bidInstance.amount}" type="currency" currencyCode="USD" /></td>
                            <td valign="top" class="value">${fieldValue(bean: bidInstance, field: "date")}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
        </div>
    </body>
</html>
